/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 配置方式（0-从数据模版中选择，1-自定义配置）
 *
 * @author hxloongs
 * @date 2024-10-16
 */
@AllArgsConstructor
@Getter
public enum IsfdDatasourceTaskTargetConfigMethodEnum {
    TEMPLATE(0, "从数据模版中选择"),
    CUSTOMIZE(1, "自定义配置");

    private final Integer value;
    private final String desc;

    public static String getDescByValue(Integer value) {
        IsfdDatasourceTaskTargetConfigMethodEnum isfdDatasourceTaskTargetConfigMethodEnum = forValue(value);
        if (isfdDatasourceTaskTargetConfigMethodEnum == null) {
            return null;
        }
        return isfdDatasourceTaskTargetConfigMethodEnum.getDesc();
    }

    public static IsfdDatasourceTaskTargetConfigMethodEnum forValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (IsfdDatasourceTaskTargetConfigMethodEnum isfdDatasourceTaskTargetConfigMethodEnum : IsfdDatasourceTaskTargetConfigMethodEnum.values()) {
            if (isfdDatasourceTaskTargetConfigMethodEnum.getValue().equals(value)) {
                return isfdDatasourceTaskTargetConfigMethodEnum;
            }
        }
        return null;
    }

    public static IsfdDatasourceTaskTargetConfigMethodEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdDatasourceTaskTargetConfigMethodEnum isfdDatasourceTaskTargetConfigMethodEnum : IsfdDatasourceTaskTargetConfigMethodEnum.values()) {
            if (desc.equals(isfdDatasourceTaskTargetConfigMethodEnum.getDesc())) {
                return isfdDatasourceTaskTargetConfigMethodEnum;
            }
        }
        return null;
    }
}
